<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" media="screen" href="../../css/bootstrap.min.css">
</head>
<body>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
	<form class="form-horizontal" onsubmit="return false" id="form">
		<fieldset>
			<input type="hidden" id="id" name="id">
			<div class='form-group'>
				<label class='col-md-2 control-label'>saleUnit</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='saleUnit' type='text' name='saleUnit' id='saleUnit' data-bv-notempty='true' data-bv-notempty-message='saleUnit 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>weight</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='weight' type='text' name='weight' id='weight' data-bv-notempty='true' data-bv-notempty-message='weight 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>productArea</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='productArea' type='text' name='productArea' id='productArea' data-bv-notempty='true' data-bv-notempty-message='productArea 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>wareQD</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='wareQD' type='text' name='wareQD' id='wareQD' data-bv-notempty='true' data-bv-notempty-message='wareQD 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>imagePath</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='imagePath' type='text' name='imagePath' id='imagePath' data-bv-notempty='true' data-bv-notempty-message='imagePath 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>param</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='param' type='text' name='param' id='param' data-bv-notempty='true' data-bv-notempty-message='param 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>state</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='state' type='text' name='state' id='state' data-bv-notempty='true' data-bv-notempty-message='state 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>sku</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='sku' type='text' name='sku' id='sku' data-bv-notempty='true' data-bv-notempty-message='sku 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>brandName</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='brandName' type='text' name='brandName' id='brandName' data-bv-notempty='true' data-bv-notempty-message='brandName 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>upc</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='upc' type='text' name='upc' id='upc' data-bv-notempty='true' data-bv-notempty-message='upc 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>category</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='category' type='text' name='category' id='category' data-bv-notempty='true' data-bv-notempty-message='category 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>name</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='name' type='text' name='name' id='name' data-bv-notempty='true' data-bv-notempty-message='name 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>introduction</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='introduction' type='text' name='introduction' id='introduction' data-bv-notempty='true' data-bv-notempty-message='introduction 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>skuId</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='skuId' type='text' name='skuId' id='skuId' data-bv-notempty='true' data-bv-notempty-message='skuId 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>jdPrice</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='jdPrice' type='text' name='jdPrice' id='jdPrice' data-bv-notempty='true' data-bv-notempty-message='jdPrice 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>price</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='price' type='text' name='price' id='price' data-bv-notempty='true' data-bv-notempty-message='price 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>normalPrice</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='normalPrice' type='text' name='normalPrice' id='normalPrice' data-bv-notempty='true' data-bv-notempty-message='normalPrice 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>merchantsPrice</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='merchantsPrice' type='text' name='merchantsPrice' id='merchantsPrice' data-bv-notempty='true' data-bv-notempty-message='merchantsPrice 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>marketPrice</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='marketPrice' type='text' name='marketPrice' id='marketPrice' data-bv-notempty='true' data-bv-notempty-message='marketPrice 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>tax</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='tax' type='text' name='tax' id='tax' data-bv-notempty='true' data-bv-notempty-message='tax 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>taxPrice</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='taxPrice' type='text' name='taxPrice' id='taxPrice' data-bv-notempty='true' data-bv-notempty-message='taxPrice 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>nakedPrice</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='nakedPrice' type='text' name='nakedPrice' id='nakedPrice' data-bv-notempty='true' data-bv-notempty-message='nakedPrice 不能为空'>
				</div>
			</div>
			<div class='form-group'>
				<label class='col-md-2 control-label'>type</label>
				<div class='col-md-10'>
					<input class='form-control' placeholder='type' type='text' name='type' id='type' data-bv-notempty='true' data-bv-notempty-message='type 不能为空'>
				</div>
			</div>



			<div class="form-actions">
				<div class="row" align="center">
					<div class="col-md-12">
					    <button class="btn btn-primary" onclick="location.href='goodsList.html'">返回</button>
						<button class="btn btn-primary" type="submit" onclick="update()">
							<i class="fa fa-save"></i> 保存
						</button>
					</div>
				</div>
			</div>

		</fieldset>
	</form>
</div>
	<script type="text/javascript" src="../../js/libs/jquery-2.1.1.min.js"></script>
	<script type="text/javascript" src="../../js/jq.js"></script>
	<script type="text/javascript" src="../../js/plugin/bootstrapvalidator/bootstrapValidator.min.js"></script>
	<script type="text/javascript" src="../../js/common.js"></script>
	<script type="text/javascript" src="../../layui/layui.js"></script>
	<script type="text/javascript">
		layui.use(['layer','laydate'], function(){
		    var layer = layui.layer;
		});
		
		initData();
		
		function initData(){
			var id = getUrlParam("id");
			if(id != ""){
				$.ajax({
					type : 'get',
					url : '/goodss/'+id,
					async : false,
					success : function(data) {
						$('#id').val(data.id);
						$('#saleUnit').val(data.saleUnit);
						$('#weight').val(data.weight);
						$('#productArea').val(data.productArea);
						$('#wareQD').val(data.wareQD);
						$('#imagePath').val(data.imagePath);
						$('#param').val(data.param);
						$('#state').val(data.state);
						$('#sku').val(data.sku);
						$('#brandName').val(data.brandName);
						$('#upc').val(data.upc);
						$('#category').val(data.category);
						$('#name').val(data.name);
						$('#introduction').val(data.introduction);
						$('#skuId').val(data.skuId);
						$('#jdPrice').val(data.jdPrice);
						$('#price').val(data.price);
						$('#normalPrice').val(data.normalPrice);
						$('#merchantsPrice').val(data.merchantsPrice);
						$('#marketPrice').val(data.marketPrice);
						$('#tax').val(data.tax);
						$('#taxPrice').val(data.taxPrice);
						$('#nakedPrice').val(data.nakedPrice);
						$('#type').val(data.type);
						$('#createTime').val(data.createTime);

					}
				});
			}
		}

		function update() {
			$('#form').bootstrapValidator();
			var bootstrapValidator = $("#form").data('bootstrapValidator');
			bootstrapValidator.validate();
		    if(!bootstrapValidator.isValid()){
			   return;
		    }
		    
		    var formdata = $("#form").serializeObject();

			$.ajax({
				type : 'put',
				url : '/goodss',
				contentType: "application/json; charset=utf-8",  
				data : JSON.stringify(formdata),
				success : function(data) {
					layer.msg("修改成功", {shift: -1, time: 1000}, function(){
                        location.href = "goodsList.html";
                    });
				}
			});
		}
		
	</script>
</body>
</html>
